package com.ehotting.mqbd.core.service;

import com.ehotting.eaf.redis.service.RedisService;
import com.ehotting.mqbd.api.MQDBConstants;
import com.ehotting.mqbd.api.bean.solver.SolverInfoBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class AgentRefSolverService {

    @Autowired
    private RedisService redisService;

    public void setSolverRefAgentId(String agentId, SolverInfoBean serverInfo){
        redisService.setCacheObject(MQDBConstants.AGENT_REF_SOLVER_IP +agentId,serverInfo,5L, TimeUnit.DAYS);
    }

    public SolverInfoBean getSolverRefAgentId(String agentId){
        return redisService.getCacheObject(MQDBConstants.AGENT_REF_SOLVER_IP +agentId);
    }

    public void deleteSolverRefAgentId(String agentId){
        redisService.deleteObject(MQDBConstants.AGENT_REF_SOLVER_IP + agentId);
    }

}
